package com.karaoke.android.home.binding

import android.databinding.BindingAdapter
import android.graphics.drawable.Drawable
import android.view.SurfaceHolder
import android.view.SurfaceView

import com.karaoke.android.data.domain.ScrollText
import com.karaoke.android.home.widget.PopupButton
import com.karaoke.android.home.widget.SeekArc
import com.karaoke.android.player.TextSurface

import java.util.ArrayList

/**
 * Created by allen on 2017/4/15.
 */

object DataBindingAdapter
{

    @BindingAdapter("surfaceCallBack")
    @JvmStatic
    fun surfaceCallBack(view: SurfaceView, callback: SurfaceHolder.Callback)
    {
        view.holder.addCallback(callback)
    }

    @BindingAdapter("scrollTexts")
    @JvmStatic
    fun scrollTexts(surface: TextSurface, texts: ArrayList<ScrollText>)
    {
        surface.scrollTexts = texts
    }

    @BindingAdapter("listener")
    @JvmStatic
    fun setListener(seek: SeekArc, l: SeekArc.OnSeekArcChangeListener)
    {
        seek.setOnSeekArcChangeListener(l)
    }

    @BindingAdapter("text")
    @JvmStatic
    fun setText(button: PopupButton, text: String)
    {
        button.title = text
    }

    @BindingAdapter("iconBackground")
    @JvmStatic
    fun setIconBackground(button: PopupButton, drawable: Drawable)
    {
        button.iconBtn.background = drawable
    }

    @BindingAdapter("icon")
    @JvmStatic
    fun setIcon(button: PopupButton, resId: Int)
    {
        button.icon = resId
    }
}
